func rob(nums []int) int {
    /*
        198
        1. dp[i] 抢到第i号房间，抢到的最大金额

        2. dp[i] = max(dp[i-2]+value[i], dp[i-1])

        3. dp[1] = value[0]
           dp[2] = max(value[0], value[1])

        4. 从前往后遍历
    
        5. 推导dp数组
    
    */
    if len(nums) == 1 {
        return nums[0]
    }
    if len(nums) == 0 {
        return 0
    }
    dp := make([]int, len(nums)+1)
    dp[1] = nums[0]
    dp[2] = max(nums[0], nums[1])
    for i:=3; i<=len(nums); i++{
        dp[i] = max(dp[i-2]+nums[i-1], dp[i-1])
    }
    return dp[len(nums)]
}

func max(a, b int) int {
    if a > b {
        return a
    }
    return b
}